// Main class for LUA scripting
// can load and run LUA script from file

#pragma once

#ifdef _WIN32
// using C++ and lua has been compiled as C code)
extern "C" {
#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"
}
#endif

// This is the only header we need to include for LuaBind to work
#include "luabind/luabind.hpp"

#include <string>

#include "../engine/engineSettings.h"

// default functions in lua
#define LUA_INIT	"_init"
#define LUA_CLEAN	"_clean"
#define LUA_UPDATE	"_update"

// lua input table
#define LUA_EXTERN  "_extern"

namespace LuaScript
{

class LuaScript
{
public:
	LuaScript();
	virtual ~LuaScript(void);

	// initialization of script
	int initScript(std::string filename);

	void pushLuaTable();
	// LUA functions
	void _init();
	void _clean();
	void _update();

	// get-set
	lua_State * getLuaState();
	void setLuaState(lua_State *state);

	luabind::object * getTable();
protected:
	luabind::object table;
	// default structure for pushing class reference or object
	// pointer to script
	virtual void bindClass();

	// try to load script file return 0 = OK
	int loadScript(std::string filename);

	lua_State *LuaState;
	bool loadingOK;
};

}
